package org.brisling.service.sysman;

import java.util.List;

import org.brisling.domain.sysman.Department;
import org.brisling.repository.sysman.inf.DepartmentRepo;
import org.brisling.service.common.BaseTreeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

@RestController
public class DepartmentService extends BaseTreeService {
	
	@Autowired
	private DepartmentRepo deptRepo;
	
	
	/**
	 * 获取业务主页面 
	 * @return
	 */
	@RequestMapping("/department/mainPage.action")
	public ModelAndView getMainPage(){
		return new ModelAndView("/sysman/department/departmentMain");
	}
	
	/**
	 * 获取业务编辑页面
	 * @return
	 */
	@RequestMapping("/department/editPage.action")
	public ModelAndView getEditPage(){
		return new ModelAndView("/sysman/department/departmentEdit");
	}
	
	/**
	 * 获取组织架构树
	 * @param id
	 * @return
	 */
	@RequestMapping("/department/getTree.action")
	@SuppressWarnings("unchecked")
	public List<Department> getTreeNode(@RequestParam(value="id",required=false) Long id){
		return (List<Department>) super.getNode(deptRepo, id);
	}
	
	/**
	 * 删除组织节点
	 * @param id
	 */
	@RequestMapping("/department/delDepartment.action")
	public void delDepartment(@RequestParam(value="id",required=false) Long id){
		deptRepo.delete(id);
	}
	
	

}
